import {
  http
} from './common'
const baseUrl = 'https://www.waibizi.com'

/**
 * 用户相关业务
 */
const getToken = (data) => http('POST', `${baseUrl}/oauth/token`, data)
const login = (data) => http('POST', `${baseUrl}/user/login`, data)
const getUserInfo = (data) => http('get', `${baseUrl}/user/view/info`, data)
const resetPassword = (data) => http('put', `${baseUrl}/user/update/password${data}`, data, {
  "Content-Type": "application/json; charset=UTF-8"
})
const logout = (data) => http('delete', `${baseUrl}/oauth/logout?access_token=` + data.access_token, {}, {
  "Content-Type": "application/json; charset=UTF-8"
})
const updateUser = (data) => http('put', `${baseUrl}/user/update/details`, data, {
  "Content-Type": "application/json; charset=UTF-8"
})

/**
 * 场地相关业务
 */
const fieldClassroomInfo = (data, query) => http('get', `${baseUrl}/field/classroom/${data}`, query)

const getFloor = (data) => http('get', `${baseUrl}/field/list/floor`, data);
const field = (data) => http('get', `${baseUrl}/field/${data}`, data)
const fieldList = (data) => http('get', `${baseUrl}/field/list/${data}`, data)
const fieldClassroom = (data) => http('get', `${baseUrl}/field/list/classroom`, data)
const fieldPeopleAmount = (data) => http('get', `${baseUrl}/field/peopleAmount`, data)


/**
 * 场地类型相关业务
 */
const fieldTypeInfo = (data) => http('get', `${baseUrl}/fieldType/info/manage`, data)
const fieldTypeList = (data) => http('get', `${baseUrl}/fieldType/list/${data}`, data)
const fieldTypeCheck = (data) => http('get', `${baseUrl}/fieldType/list/check`, data)
const fieldTypeManage = (data) => http('get', `${baseUrl}/fieldType/list/manage`, data)
const fieldTypeAll = (data) => http('get', `${baseUrl}/fieldType/listAll`, data)
const fieldTypeTop = (data) => http('get', `${baseUrl}/fieldType/top/list`, data)
// const fieldTypeUpdate = (data) => http('post', `${baseUrl}/fieldType/app/update/${data}`, data)

const fieldTypeAlloc = (data) => http('get', `${baseUrl}/field/list/alloc/${data}`, data)

const fieldTypeTime = (data) => http('get', `${baseUrl}/field/timeQuantum/${data}`)
const fieldTypeUpdate = (fieldTypeId, data) => http('post', `${baseUrl}/fieldType/app/update/${fieldTypeId}`, data, {
  "Content-Type": "application/json; charset=UTF-8"
})

const unAssignList = (data) => http('get', `${baseUrl}/applyForm/list/unAssign`, data)
const assignList = (data) => http('get', `${baseUrl}/applyForm/list/assign`, data)

/**
 * 审批申请表相关业务
 */
const applyAssign = (data, query) => http('post', `${baseUrl}/applyForm/assign${query}`, data)
const applyCheck = (data) => {
  let {
    applyFormId,
    ...other
  } = data
  console.log('applyFormId============>', applyFormId)
  http('post', `${baseUrl}/applyForm/check/${applyFormId}`, other)
}


/**
 * 申请表相关业务
 */
const applyForm = (data) => http('get', `${baseUrl}/applyForm/${data}`, data)
const applyRender = (data) => http('get', `${baseUrl}/applyForm/apply/render`, data)
const applyClose = (data) => http('post', `${baseUrl}/applyForm/cancel/${data}`, data)
const applyList = (data) => http('get', `${baseUrl}/applyForm/list/apply`, data)
const applyApproval = (data) => http('get', `${baseUrl}/applyForm/list/approval`, data)
const applyUnApproval = (data) => http('get', `${baseUrl}/applyForm/list/unApproval`, data)
const applySubmit = (data) => http('post', `${baseUrl}/applyForm/submit`, data, {
  "Content-Type": "application/json; charset=UTF-8"
})
const applyParam = (data) => http('get', `${baseUrl}/applyForm/param/${data}`, data)




export default {
  // 用户
  updateUser,
  getToken,
  login,
  logout,
  getUserInfo,
  resetPassword,

  //申请表相关业务
  applyForm,
  applyRender,
  applyClose,
  applyList,
  applyApproval,
  applyUnApproval,
  applySubmit,
  applyParam,

  //审批申请表相关业务
  applyAssign,
  applyCheck,

  //场地类型相关业务
  fieldTypeInfo,
  fieldTypeList,
  fieldTypeCheck,
  fieldTypeTime,
  fieldTypeAlloc,
  fieldTypeManage,
  fieldTypeAll,
  fieldTypeTop,
  fieldTypeUpdate,

  // 场地相关业务
  getFloor,
  field,
  fieldList,
  fieldClassroom,
  fieldPeopleAmount,
  fieldClassroomInfo,

  unAssignList,
  assignList
}